<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
    	<title>叮咚老师-绑定园所</title>
        
        <!-- 引入 WeUI -->
        <link rel="stylesheet" href="<?php echo base_url()?>/public/assets/css/weui.css"/>
        <link rel="stylesheet" href="<?php echo base_url()?>/public/assets/css/font-awesome.css">
        <link rel="stylesheet" type="text/css" href="<?php echo base_url()?>public/assets/css/h5/bind.css">
        <script type="text/javascript" src="<?php echo base_url()?>/public/assets/js/jquery.min.js"></script>
        
    </head>
    <body>

<div class="contain" id="city" style="display: block;">
    <p class="current">当前城市：<label id="area_label"><?php echo $area_title?></label>&nbsp;&nbsp;<label id="city_label"></label></p>
    <div class="weui_cells weui_cells_radio">
        <label class="weui_cell weui_check_label">
            <div class="weui_cell_bd weui_cell_primary">
                <p>全部</p>
            </div>
            <div class="weui_cell_ft">
                <input checked area_id="<?php echo $area_id;?>" city_title="全部" type="radio" class="weui_check" name="radio1" value="0">
                <span class="weui_icon_checked"></span>
            </div>
        </label>
        <?php foreach ($city_info as $k=>$v){?>
        <label class="weui_cell weui_check_label">
            <div class="weui_cell_bd weui_cell_primary">
                <p><?php echo $v['title']?></p>
            </div>
            <div class="weui_cell_ft">
                <input area_id="<?php echo $v['area_id']?>" city_title="<?php echo $v['title']?>" type="radio" class="weui_check" name="radio1" value="<?php echo $v['id']?>">
                <span class="weui_icon_checked"></span>
            </div>
        </label>
        <?php }?>
        
    </div>
    
    <span class="weui_btn weui_btn_plain_primary" id="btn1">确定</span>
    <span class="weui_btn weui_btn_plain_default">返回</span>
    
    <div class="weui_dialog_confirm" id="dialog1" style="display: none">
        <div class="weui_mask"></div>
        <div class="weui_dialog">
            <div class="weui_dialog_hd"><strong class="weui_dialog_title"></strong></div>
            <div class="weui_dialog_ft">
                <a href="javascript:void(0);" class="weui_btn_dialog default">取消</a>
                <a href="javascript:void(0);" class="weui_btn_dialog primary">确定</a>
            </div>
        </div>
    </div>
</div>



<script type="text/javascript">
    $(document).ready(function(){
        $("#city .weui_btn_plain_default").click(function(){
            location.href='<?php echo base_url()?>bind/area';
        });
        
        $("#city label").click(function(){
            var title = $('[name="radio1"]:checked').attr('city_title');
            $("#city_label").text(title);
        });

        $("#city label:eq(0)").click();
        
        $(".primary").click(function(){
        	var city_id = $('[name="radio1"]:checked').val();
        	var area_id = $('[name="radio1"]:checked').attr('area_id');
        	var area_title = $('#area_label').text();
        	var city_title = $('#city_label').text();
        	
        	location.href='<?php echo base_url()?>bind/nursery?cid='+city_id+'&aid='+area_id+'&ct='+city_title+'&at='+area_title;
        });
        $(".default").click(function(){
            $("#dialog1").hide();
        });

        $("#city #btn1").click(function(){
        	var area_title = $('#area_label').text();
        	var city_title = $('#city_label').text();
        	var cur_city_id = <?php echo $city_id;?>;
        	var sel_city_id = $('[name="radio1"]:checked').val();
        	
        	if(cur_city_id && cur_city_id != sel_city_id){
        		$("#dialog1").find('.weui_dialog_title').text('确定切换当前城市为 '+area_title+city_title+'？');
                $("#dialog1").show();
        	}else{
        		$(".primary").click();
        	}
        	
        });
        
    });
</script>

</body>
</html>